<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<title>申请店铺</title>
	<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/frame/mui/js/mui.min.js"></script>
	<link rel="stylesheet" href="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/frame/mui/css/mui.min.css">
	<link href="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/css/app.css?v=042404" rel="stylesheet" />
	<link rel="stylesheet" href="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/frame/sui/css/SUI.css?v">
	<link rel="stylesheet" href="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/font/iconfont.css">
	<link href="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/frame/mui/css/mui.picker.css" rel="stylesheet" />
	<link href="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/frame/mui/css/mui.poppicker.css" rel="stylesheet" />

	<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/frame/mui/js/mui.min.js"></script>
	<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/frame/mui/js/mui.picker.js"></script>
	<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/frame/mui/js/mui.poppicker.js"></script>
	<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/frame/mui/js/city.data-3.js" type="text/javascript" charset="utf-8"></script>
</head>
<style type="text/css">
		.suiLineInput dl input{margin: 0!important;padding:0;}
		.suiLineInput dl{min-height: 41px !important}
		.suiTag{margin: 0}
		.sure{margin-bottom: 20px;}
		button.mui-btn{border: #e54242}
		div.suiLineInput dl dt{width: 35%}
		div.suiLineInput dl dd{width: 65%}
		.sure{margin-bottom: 20px !important;}
</style>
<body class="storeapply">
	<p class="suiTag">基本信息</p>
	<form id="form">
	<div class="suiLineInput strong">
		<input type="hidden" name="id" value="{{.json.id}}">
		<dl class="uploadImg">
			<dt>图标</dt>
			<dd style="background-image: url({{if .json.pathname}}{{.json.pathname}}{{else}}/static/wechat/img/add.png{{end}});">
				<input type="file" onchange='sword_uppic(this,"shop",1)' accept="image/*">
				<input type="hidden" name="logo" value="{{.json.logo}}">
			</dd>
		</dl>
		<dl>
			<dt>店铺名</dt>
			<dd><input type="text" placeholder="请输入店铺名" value="{{.json.name}}" name="name"></dd>
		</dl>
		<dl>
			<dt>店铺简介</dt>
			<dd><input type="text" placeholder="请输入店铺简介" value="{{.json.intr}}" name="intr"></dd>
		</dl>
		<dl>
			<dt>联系人</dt>
			<dd>
				<input type="text" placeholder="请输入联系人" value="{{.json.person}}" name="person">
			</dd>
		</dl>
		<dl>
			<dt>联系电话</dt>
			<dd>
				<input type="tel" placeholder="请输入联系电话" value="{{.json.tel}}" name="tel">
			</dd>
		</dl>
		<dl>
			<dt>所在地</dt>
			<dd id="add">{{if .json.shen}}{{.json.shen}}{{.json.shi}}{{.json.qu}}{{else}}请选择所在地{{end}}</dd>
			<input type="hidden" name="province" value="{{.json.province}}">
			<input type="hidden" name="city" value="{{.json.city}}">
			<input type="hidden" name="area" value="{{.json.area}}">
		</dl>
	</div>
	<p class="suiTag">企业认证</p>
	<div class="suiLineInput strong">
		<dl>
			<dt>认证类型</dt>
			<dd id="type">{{if .json.type}}{{if eq .json.type "0"}}营业执照认证{{else}}其他证件认证{{end}}{{else}}请选择认证类型{{end}}</dd>
			<input type="hidden" name="type" value="{{.json.type}}">
		</dl>
		<dl class="uploadImg">
			<dt>手持身份证照</dt>
			<dd style="background-image: url({{if .json.cpath}}{{.json.cpath}}{{else}}/static/wechat/img/add.png{{end}});">
				<input type="file" onchange='sword_uppic(this,"shop",1)' accept="image/*">
				<input type="hidden" name="cardimg" value="{{.json.cardimg}}">
			</dd>
		</dl>
		<dl id="businesslicense">
			<dt>营业执照号码 </dt>
			<dd>
				<input type="tel" placeholder="请输入营业执照号码" value="{{.json.businesslicense}}" name="businesslicense">
			</dd>
		</dl>
		<dl class="uploadImg" id="license">
			<dt>营业执照</dt>
			<dd style="background-image: url({{if .json.lpath}}{{.json.lpath}}{{else}}/static/wechat/img/add.png{{end}});">
				<input type="file" onchange='sword_uppic(this,"shop",1)' accept="image/*">
				<input type="hidden" name="license" value="{{.json.license}}">
			</dd>
		</dl>
		<dl class="uploadImg" id="theimg">
			<dt>其他证件</dt>
			<dd style="background-image: url({{if .json.tpath}}{{.json.tpath}}{{else}}/static/wechat/img/add.png{{end}});">
				<input type="file" onchange='sword_uppic(this,"shop",1)' accept="image/*">
				<input type="hidden" name="theimg" value="{{.json.theimg}}">
			</dd>
		</dl>
	</div>
	</form>
	<button class="sure" id="save">保存</button>
</body>
</html>
<script type="text/javascript" src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/frame/sui/js/SUI.js"></script>
<script type="text/javascript" src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/js/zepto.min.js"></script>
<script type="text/javascript" src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/js/sword_uppic.js"></script>
<script type="text/javascript">
			//普通示例
	var userPicker = new mui.PopPicker({layer:3});
	userPicker.setData(cityData3);
	var add = doc.getElementById('add');
	add.addEventListener('tap', function(event) {
		userPicker.show(function(items) {
			add.innerHTML =items[0].text + ' '+items[1].text+' ' +items[2].text;
			$('input[name="province"]').val(items[0].value)
			$('input[name="city"]').val(items[1].value)
			$('input[name="area"]').val(items[2].value)
		});
	}, false);
	var userPicker2 = new mui.PopPicker();
	userPicker2.setData([{
		text: '营业执照认证',
		value:'0'
	}, {
		text: '其他证件认证',
		value:'1'
	}]);
	var type = document.getElementById('type');
	var type2=document.getElementsByName("type")[0]
	type.addEventListener('tap', function(event) {
		userPicker2.show(function(items) {
			type.innerHTML =items[0].text;
			type2.value=items[0].value
			typechange()
		});
	}, false);
	var theimg = document.getElementById('theimg');
	var license = document.getElementById('license');
	var businesslicense = document.getElementById('businesslicense');
	function typechange(){
		var tv=type2.value
		if(tv==""){
			theimg.style.display='none'
			license.style.display='none'
			businesslicense.style.display='none'
		}else if(tv=="0"){
			theimg.style.display='none'
			license.style.display='block'
			businesslicense.style.display='block'
		}else if(tv=="1"){
			theimg.style.display='block'
			license.style.display='none'
			businesslicense.style.display='none'
		}
	}
	typechange()
	document.getElementById('save').addEventListener('tap',function(){
		var that=this
		var form=serialize('form')
		if(form.logo==""){
			mui.toast("请上传图标~");return false;
		}
		if(form.name==""){
			mui.toast("请输入店铺名~");return false;
		}
		if(form.person==""){
			mui.toast("请输入联系人~");return false;
		}
		if(form.tel==""){
			mui.toast("请输入联系电话~");return false;
		}
		if(form.province==""){
			mui.toast("请选择所在地~");return false;
		}
		if(form.type==""){
			mui.toast("请选择类型~");return false;
		}
		if(form.cardimg==""){
			mui.toast("请上传手持身份证照~");return false;
		}
		if(!form.type){
			mui.toast("请选择认证类型~");return false;
		}
		if(form.type==0){
			if(form.businesslicense==""){
				mui.toast("请输入营业执照号码~");return false;
			}
			if(form.license==""){
				mui.toast("请上传营业执照~");return false;
			}
		}else{
			if(form.theimg==""){
				mui.toast("请上传其他证件~");return false;
			}
		}
		that.disabled=true
		mui.ajax(window.location.href,{
			type:'post',
			data:form,
			dataType:'json',
			timeout:1000,
			success: function(data){
			if (data==1) {
				mui.alert("提交成功，请等待审核","",function () {
					window.location.href="/mobile/my"
				});
			}else if(data==2){
				mui.toast("请不要重复提交!");
			}else{
				mui.toast("网络繁忙，请重试~");
			}
			that.disabled=false
			},
			error: function(xhr, type){
				mui.toast("网络慢，请重试");
				that.disabled=false
			// 即使加载出错，也得重置
			}
		});

	})
</script>